package com.company.jrlz.service.opcua.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by ziye on 2023/9/6
 */
@Configuration
public class OpcUaConfiguration {

    @Bean
    OpcUaClientFactory opcUaClientFactory(OpcUaProperties opcUaProperties) {
        AutoReconnectUaClientFactory opcUaClientFactory = new AutoReconnectUaClientFactory();
        opcUaClientFactory.setUaAddress(opcUaProperties.getAddress());
        return opcUaClientFactory;
    }



    @Bean(destroyMethod = "close")
    OpcUaClientTemplate opcUaClientTemplate(OpcUaClientFactory opcUaClientFactory, OpcUaProperties opcUaProperties) {
        return new OpcUaClientTemplate(opcUaClientFactory, opcUaProperties);
    }
}
